window.onscroll = function(){
	console.log(this.pageYOffset);
	var nav = document.querySelector(".nav");
	if(this.pageYOffset>300){
		nav.style.position = "fixed";
		nav.style.left = 0;
		nav.style.top = 0;
	}else{
		nav.style.position = "static";
		nav.style.left = 0;
		nav.style.top = 0;
	}
}

window.onload = function(){
	var huojian = document.querySelector(".huojian");
	huojian.onclick = function(){
		var step = 100;
		var y = window.pageYOffset;
		var interId = setInterval(function(){
			step = step +10;
			y = y - step;
			if(y<=0){
				y=0;
				clearInterval(interId);
			}
				scrollTo(0,y);
			},10)
	}


}